/* MoonIconView.m
 * Part of the Moon application for the NeXT computer.
 * Author:  Geoffrey S. Knauth
 * Date:    January 4, 1992
 *
 * Permission to copy this program is hereby granted under the terms
 * of the Free Software Foundation's GNU General Public License.
 */

#import <dpsclient/psops.h>		/* PSsetgray */
#import "MoonIconView.h"
#import "all.h"

@implementation MoonIconView

- initFrame :(const NXRect *)frameRect
{
    [super initFrame:frameRect];
    [self setOpaque:YES];
    return self;
}

- drawSelf :(const NXRect *)rects :(int)rectCount
{
    NXPoint center = {NX_WIDTH(&bounds)/2., NX_HEIGHT(&bounds)/2.};
    float yradius = NX_HEIGHT(&bounds)/2.-2.;
    float xradius = yradius;

    PSsetgray(NX_LTGRAY);
    NXRectFill(&bounds);

  /* draw the image of the moon */
    PSsetgray(NX_WHITE);
    PSarc(center.x, center.y, yradius, 0., 360.);
    PSfill();

  /* now draw the shadow over that part hidden from the sun */
    DrawMoonShadow([self phase], &center, xradius, yradius, NX_BLACK);

    return self;
}

- (float) phase
{
    return phase;
}

- setPhase :(float) val
{
    phase = val;
    return self;
}

@end
